package top.huxy.boot.controller.admin;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.huxy.boot.annotation.RequestRemake;
import top.huxy.boot.model.vo.VOVisitorCityInfo;
import top.huxy.boot.service.impl.DashboardServiceImpl;
import top.huxy.boot.util.obj.Result;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Classname DashboardController
 * @Description DashboardController
 * @Date 2021/9/30 22:49
 * @Created by huxy
 */
@RestController
@RequestMapping("/admin/dashboard")
public class DashboardController {

    DashboardServiceImpl dashboardService;

    public DashboardController(DashboardServiceImpl dashboardService) {
        this.dashboardService = dashboardService;
    }

    @GetMapping("/getVisitorCityInfo")
    @RequestRemake("获取访客城市信息")
    public Result getVisitorCityInfo() {
        List<VOVisitorCityInfo> data = dashboardService.getVisitorCityInfo();
        return Result.success(data);
    }

    @GetMapping("/getVisitor7")
    @RequestRemake("获取7日访客信息")
    public Result getVisitor7() {
        Map<String, List<Object>> data = dashboardService.getVisitor7();
        return Result.success(data);
    }

    @GetMapping("/getVisitor30")
    @RequestRemake("获取30日访客信息")
    public Result getVisitor30() {
        Map<String, List<Object>> data = dashboardService.getVisitor30();
        return Result.success(data);
    }

    @GetMapping("/getTopData")
    @RequestRemake("获取Top信息")
    public Result getTopData(){
        HashMap<String, Object> result= dashboardService.getTopData();
        return Result.success(result);
    }
}
